package com.siashan.toolkit.captcha.easy;

import com.wf.captcha.ArithmeticCaptcha;
import com.wf.captcha.ChineseCaptcha;
import com.wf.captcha.GifCaptcha;
import com.wf.captcha.SpecCaptcha;
import com.wf.captcha.base.Captcha;
import lombok.Getter;
import lombok.Setter;

/**
 * Easy图形验证码构造器
 *
 * @author siashan
 * @since v1.0.3
 **/
@Setter
@Getter
public class EasyCaptchaBuilder {


    /**
     * 构造EasyCaptcha
     *
     * @return EasyCaptcha
     */
    public static EasyCaptcha build() {
        SpecCaptcha captcha = new SpecCaptcha(130, 48);
        return new EasyCaptcha(captcha);
    }

    /**
     * 构造EasyCaptcha
     *
     * @param captchaType 验证码类型
     * @return EasyCaptcha
     */
    public static EasyCaptcha build(EasyCaptchaType captchaType) {
        Captcha captcha = null;
        switch (captchaType) {
            case PNG:
                captcha = new SpecCaptcha();
                break;
            case MATH:
                captcha = new ArithmeticCaptcha();
                break;
            case GIF:
                captcha = new GifCaptcha();
                break;
            case CHINESE:
                captcha = new ChineseCaptcha();
            default:
                break;

        }
        return new EasyCaptcha(captcha);
    }
}
